<template>
	<div id="space-analyze-view">
		<h2>
			空间图库分析
			<span v-if="queryAll">全部空间</span>
			<span v-else-if="queryPublic">公共图库</span>
			<span v-else>
				<a :href="`/space/${spaceId}`" target="_blank"> 空间 id：{{ spaceId }} </a>
			</span>
		</h2>
		<div style="margin-bottom: 16px"></div>
		<a-row :gutter="[16, 16]">
			<a-col :xs="24" :md="12">
				<!--  空间资源使用分析  -->
				<SpaceUsageAnalyze :spaceId="spaceId" :queryAll="queryAll" :queryPublic="queryPublic" />
			</a-col>
			<a-col :xs="24" :md="12">
				<!--  空间资源分类分析  -->
				<SpaceCategoryAnalyze :spaceId="spaceId" :queryAll="queryAll" :queryPublic="queryPublic" />
			</a-col>
			<a-col :xs="24" :md="12">
				<!--  空间资源标签分析  -->
				<SpaceTagAnalyze :spaceId="spaceId" :queryAll="queryAll" :queryPublic="queryPublic" />
			</a-col>
			<a-col :xs="24" :md="12">
				<!--  空间资源大小分析  -->
				<SpaceSizeAnalyze :spaceId="spaceId" :queryAll="queryAll" :queryPublic="queryPublic" />
			</a-col>
			<a-col :xs="24" :md="12">
				<!--  空间用户上传分析  -->
				<SpaceUserAnalyze :spaceId="spaceId" :queryAll="queryAll" :queryPublic="queryPublic" />
			</a-col>
			<a-col :xs="24" :md="12" v-if="isAdmin">
				<!--  空间资源排行分析  -->
				<SpaceRankAnalyze :spaceId="spaceId" :queryAll="queryAll" :queryPublic="queryPublic" />
			</a-col>
		</a-row>
	</div>
</template>

<script setup lang="ts">
import SpaceUsageAnalyze from '@/components/analyze/SpaceUsageAnalyze.vue'
import SpaceCategoryAnalyze from '@/components/analyze/SpaceCategoryAnalyze.vue'
import SpaceTagAnalyze from '@/components/analyze/SpaceTagAnalyze.vue'
import SpaceSizeAnalyze from '@/components/analyze/SpaceSizeAnalyze.vue'
import SpaceUserAnalyze from '@/components/analyze/SpaceUserAnalyze.vue'
import SpaceRankAnalyze from '@/components/analyze/SpaceRankAnalyze.vue'
import { useRoute } from 'vue-router'
import { computed } from 'vue'
import { useLoginUserStore } from '@/stores/useLoginUserStore'
import ACCESS_ENUM from '@/access/accessEnum'

const route = useRoute()

// 空间 id
const spaceId = computed(() => {
	return route.query?.spaceId as string
})

// 是否查询所有空间
const queryAll = computed(() => {
	return !!route.query?.queryAll
})

// 是否查询公共空间
const queryPublic = computed(() => {
	return !!route.query?.queryPublic
})

//判断用户是否为管理员
const loginUserStore = useLoginUserStore()
const loginUser = loginUserStore.loginUser
const isAdmin = computed(() => {
	return loginUser.userRole === ACCESS_ENUM.ADMIN
})
</script>
